﻿USE [HMSIndia]
GO

/****** Object:  StoredProcedure [dbo].[Proc_DeleteModulePermissions]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_DeleteModulePermissions]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_DeleteModulePermissions]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetCollectionChartData]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetCollectionChartData]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetCollectionChartData]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetDiagnosisList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetDiagnosisList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetDiagnosisList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetFindingCategoryList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetFindingCategoryList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetFindingCategoryList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetFindingsList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetFindingsList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetFindingsList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetInvestigationsList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetInvestigationsList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetInvestigationsList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetItemMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetItemMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetItemMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetLookupList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetLookupList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetLookupList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetMedicineItemsDtl]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetMedicineItemsDtl]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetMedicineItemsDtl]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetMedicineLookupItems]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetMedicineLookupItems]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetMedicineLookupItems]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetModuleList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetModuleList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetModuleList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatienLastVisitInfo]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatienLastVisitInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatienLastVisitInfo]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientAppointmentList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientAppointmentList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientAppointmentList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBill]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientBill]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientBill]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByID]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientBillByID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientBillByID]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDChargesDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientBillByIDChargesDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientBillByIDChargesDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDItemDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientBillByIDItemDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientBillByIDItemDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDPayDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientBillByIDPayDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientBillByIDPayDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientbyID]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientbyID]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientbyID]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientInflowChartData]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientInflowChartData]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientInflowChartData]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisit]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientVisit]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientVisit]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitDiagnosis]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientVisitDiagnosis]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientVisitDiagnosis]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitExamFinding]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientVisitExamFinding]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientVisitExamFinding]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitPrescription]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientVisitPrescription]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientVisitPrescription]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitProblems]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatientVisitProblems]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatientVisitProblems]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatienVisitInfo]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetPatienVisitInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetPatienVisitInfo]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetProblemsCategoryWiseList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetProblemsCategoryWiseList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetProblemsCategoryWiseList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetProblemsList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetProblemsList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetProblemsList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetSalesChartData]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetSalesChartData]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetSalesChartData]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetTemplateItems]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetTemplateItems]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetTemplateItems]
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetTreatmentProceduresList]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_GetTreatmentProceduresList]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_GetTreatmentProceduresList]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_AlertsReminder]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_AlertsReminder]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_AlertsReminder]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Banks]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Banks]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Banks]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Bill]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Bill]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Bill]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillChargesDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_BillChargesDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_BillChargesDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillItemsDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_BillItemsDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_BillItemsDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillPaymentDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_BillPaymentDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_BillPaymentDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillTemplateDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_BillTemplateDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_BillTemplateDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillTemplates]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_BillTemplates]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_BillTemplates]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DepartmentMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_DepartmentMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_DepartmentMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Diagnosis]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Diagnosis]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Diagnosis]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DiseasesMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_DiseasesMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_DiseasesMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DoctorMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_DoctorMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_DoctorMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_EmpMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_EmpMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_EmpMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Findings]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Findings]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Findings]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Investigation]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Investigation]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Investigation]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_ItemServiceMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_ItemServiceMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_ItemServiceMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_LookupsMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_LookupsMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_LookupsMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_MedicineItemsDtl]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_MedicineItemsDtl]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_MedicineItemsDtl]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatienDiagnosis]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatienDiagnosis]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatienDiagnosis]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientAddmissionInfo]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientAddmissionInfo]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientAddmissionInfo]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientAppointment]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientAppointment]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientAppointment]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientExamFinding]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientExamFinding]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientExamFinding]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientGuardians]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientGuardians]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientGuardians]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientPrescription]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientPrescription]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientPrescription]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientProblems]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientProblems]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientProblems]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientRegistration]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientRegistration]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientRegistration]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientVisits]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PatientVisits]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PatientVisits]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PrescriptionTempDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PrescriptionTempDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PrescriptionTempDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PrescriptionTemplate]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_PrescriptionTemplate]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_PrescriptionTemplate]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Problem]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_Problem]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_Problem]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_RoomMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_RoomMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_RoomMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_SecurityMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_SecurityMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_SecurityMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_SupplierMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_SupplierMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_SupplierMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_TreatmentProcedures]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_TreatmentProcedures]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_TreatmentProcedures]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_WardMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Insert_WardMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Insert_WardMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertModulePermissions]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertModulePermissions]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertModulePermissions]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPatientPayDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPatientPayDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPatientPayDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPurchaseDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPurchaseDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPurchaseMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPurchaseMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseOrder]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPurchaseOrder]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPurchaseOrder]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseOrderDtl]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPurchaseOrderDtl]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPurchaseOrderDtl]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseTaxDiscDtl]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertPurchaseTaxDiscDtl]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertPurchaseTaxDiscDtl]
GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertUserProfile]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_InsertUserProfile]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_InsertUserProfile]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Select_PrescriptionTempDetails]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Select_PrescriptionTempDetails]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Select_PrescriptionTempDetails]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_CompanyMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Update_CompanyMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Update_CompanyMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_Diagnosis]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Update_Diagnosis]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Update_Diagnosis]
GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_LookupsMaster]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_Update_LookupsMaster]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_Update_LookupsMaster]
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateFinding]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_UpdateFinding]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_UpdateFinding]
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateInvestigations]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_UpdateInvestigations]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_UpdateInvestigations]
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateProblem]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_UpdateProblem]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_UpdateProblem]
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateTreatmentProcedures]    Script Date: 09/07/2014 09:18:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Proc_UpdateTreatmentProcedures]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[Proc_UpdateTreatmentProcedures]
GO

USE [HMSIndia]
GO

/****** Object:  StoredProcedure [dbo].[Proc_DeleteModulePermissions]    Script Date: 09/07/2014 09:18:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_DeleteModulePermissions]
	@ProfileID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   DELETE FROM [dbo].[ModulePermissions] WHERE [ProfileID] = @ProfileID
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetCollectionChartData]    Script Date: 09/07/2014 09:18:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetCollectionChartData]
	@SYear int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT MONTH(ReceivedDate) AS SMonth, Amount FROM dbo.BillPayDetails WHERE    (YEAR(ReceivedDate) = @SYear)
		GROUP BY MONTH(ReceivedDate), Amount
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetDiagnosisList]    Script Date: 09/07/2014 09:18:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_GetDiagnosisList]
        
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    Select [DiagnosisID],[Diagnosis]            ,[ParentID]
           ,[Remarks] From [dbo].[Diagnosis] Order by ParentID,DiagnosisID
           
     
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetFindingCategoryList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetFindingCategoryList]  
  @FindingCategory int
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
SELECT     TOP (100) PERCENT dbo.Findings.FindingID, dbo.LookupsMaster.Name AS FindingCategory, dbo.Findings.Finding
FROM         dbo.Findings INNER JOIN
                      dbo.LookupsMaster ON dbo.Findings.FindingCategory = dbo.LookupsMaster.ID
WHERE     (dbo.Findings.FindingCategory = @FindingCategory)
ORDER BY dbo.Findings.Finding
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetFindingsList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetFindingsList]

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   SELECT    dbo.Findings.FindingID, dbo.LookupsMaster.Name AS FindingCategory, dbo.Findings.Finding
FROM         dbo.Findings INNER JOIN
                      dbo.LookupsMaster ON dbo.Findings.FindingCategory = dbo.LookupsMaster.ID
ORDER BY dbo.Findings.Finding
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetInvestigationsList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetInvestigationsList]
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   SELECT     TOP (100) PERCENT dbo.Investigations.InvestigationID, dbo.Investigations.Investigation, dbo.Investigations.Remarks, 
                      dbo.LookupsMaster.Name AS InvestigationCategory
FROM         dbo.Investigations INNER JOIN
                      dbo.LookupsMaster ON dbo.Investigations.InvestigationCategory = dbo.LookupsMaster.ID
ORDER BY dbo.Investigations.Investigation
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetItemMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


Create PROCEDURE [dbo].[Proc_GetItemMaster]  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
   SELECT     dbo.ItemServiceMaster.[ItemNo], dbo.ItemServiceMaster.Name, LookupsMaster_1.Name AS Category, dbo.ItemServiceMaster.Rate,   
                      dbo.LookupsMaster.Name AS UnitName,dbo.ItemServiceMaster.Unit, dbo.ItemServiceMaster.Remarks, dbo.ItemServiceMaster.ItemID, dbo.ItemServiceMaster.IsInventoryItem,   
                      LookupsMaster_2.Name AS SubCategory  
FROM         dbo.LookupsMaster AS LookupsMaster_2 RIGHT OUTER JOIN  
                      dbo.LookupsMaster AS LookupsMaster_1 RIGHT OUTER JOIN  
                      dbo.ItemServiceMaster INNER JOIN  
                      dbo.LookupsMaster ON dbo.ItemServiceMaster.Unit = dbo.LookupsMaster.ID ON LookupsMaster_1.ID = dbo.ItemServiceMaster.CategoryID ON   
                      LookupsMaster_2.ID = dbo.ItemServiceMaster.SubCategoryID  
ORDER BY dbo.ItemServiceMaster.Name  
END  

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetLookupList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_GetLookupList]

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT dbo.LookupsMaster.ID, dbo.LookupsMaster.Name, dbo.LookupTypes.LookupType, dbo.LookupsMaster.Remarks
	FROM   dbo.LookupsMaster INNER JOIN
      dbo.LookupTypes ON dbo.LookupsMaster.Type = dbo.LookupTypes.LookupTypeID
	ORDER BY dbo.LookupTypes.LookupType,dbo.LookupsMaster.Name
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetMedicineItemsDtl]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

  
CREATE PROCEDURE [dbo].[Proc_GetMedicineItemsDtl]    
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
SELECT     TOP (100) PERCENT dbo.ItemServiceMaster.ItemNo, dbo.ItemServiceMaster.Name, LookupsMaster_1.Name AS Category, dbo.ItemServiceMaster.Remarks, 
                      dbo.ItemServiceMaster.ItemID, LookupsMaster_2.Name AS SubCategory, dbo.MedicineItemsDtl.GenericDrug AS GenericDrugID, 
                      LookupsMaster_3.Name AS GenericDrug, dbo.MedicineItemsDtl.Mfg AS MfgID, LookupsMaster_4.Name AS Mfg, 
                      dbo.MedicineItemsDtl.MedicineType AS MedicineTypeID, dbo.LookupsMaster.Name AS MedicineType, dbo.MedicineItemsDtl.Strenght, 
                      dbo.MedicineItemsDtl.Composition, dbo.MedicineItemsDtl.ShelfNo, dbo.MedicineItemsDtl.RackNo, dbo.MedicineItemsDtl.BoxNo
FROM         dbo.LookupsMaster AS LookupsMaster_3 RIGHT OUTER JOIN
                      dbo.LookupsMaster RIGHT OUTER JOIN
                      dbo.MedicineItemsDtl INNER JOIN
                      dbo.ItemServiceMaster ON dbo.MedicineItemsDtl.ItemID = dbo.ItemServiceMaster.ItemID ON 
                      dbo.LookupsMaster.ID = dbo.MedicineItemsDtl.MedicineType LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_4 ON dbo.MedicineItemsDtl.Mfg = LookupsMaster_4.ID ON 
                      LookupsMaster_3.ID = dbo.MedicineItemsDtl.GenericDrug LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_2 ON dbo.ItemServiceMaster.SubCategoryID = LookupsMaster_2.ID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_1 ON dbo.ItemServiceMaster.CategoryID = LookupsMaster_1.ID
ORDER BY dbo.ItemServiceMaster.Name
END    
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetMedicineLookupItems]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetMedicineLookupItems]

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  SELECT     dbo.ItemServiceMaster.ItemID, dbo.ItemServiceMaster.Name, dbo.MedicineItemsDtl.GenericDrug, dbo.MedicineItemsDtl.Mfg, 
                      dbo.MedicineItemsDtl.MedicineType
FROM         dbo.ItemServiceMaster INNER JOIN
                      dbo.MedicineItemsDtl ON dbo.ItemServiceMaster.ItemID = dbo.MedicineItemsDtl.ItemID
ORDER BY dbo.ItemServiceMaster.Name
           

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetModuleList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetModuleList]
	@ProfileID int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	IF @ProfileID = 0
		SELECT [ModuleID]
			,[ModuleName]
			,[ModuleType],0 as PAdd,0 as PEdit, 0 as PDelete, 0 as PView,0 as PPrint
			FROM [dbo].[ModuleList] order by [ModuleName]
	Else
		SELECT     dbo.ModuleList.ModuleID, dbo.ModuleList.ModuleName, dbo.ModuleList.ModuleType, dbo.ModulePermissions.PAdd, dbo.ModulePermissions.PEdit, 
                      dbo.ModulePermissions.PDelete, dbo.ModulePermissions.PView,dbo.ModulePermissions.PPrint
		FROM         dbo.ModuleList LEFT OUTER JOIN
                      dbo.ModulePermissions ON dbo.ModuleList.ModuleID = dbo.ModulePermissions.ModuleID
		WHERE   (dbo.ModulePermissions.ProfileID IS NULL) OR
                      (dbo.ModulePermissions.ProfileID = @ProfileID) order by [ModuleName]
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatienLastVisitInfo]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatienLastVisitInfo]  
           (@PatientId bigint)  
  
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
SELECT     dbo.PatientRegistration.Age, dbo.Problems.Problem, dbo.PatientVisits.VisitID, dbo.PatientVisits.VisitDataTime, 
                      dbo.DoctorMaster.SurName + ' ' + dbo.DoctorMaster.FirstName + ' ' + dbo.DoctorMaster.LastName AS Doc
FROM         dbo.PatientVisits INNER JOIN
                      dbo.PatientRegistration ON dbo.PatientVisits.PatientID = dbo.PatientRegistration.PatientId INNER JOIN
                      dbo.Problems ON dbo.PatientVisits.CompalinedDiseases = dbo.Problems.ProblemID INNER JOIN
                      dbo.DoctorMaster ON dbo.PatientVisits.ConsultingDoc = dbo.DoctorMaster.DrID
WHERE     (dbo.PatientVisits.PatientID = @PatientId) AND (dbo.PatientVisits.VisitID =
                          (SELECT     MAX(VisitID) AS Expr1
                            FROM          dbo.PatientVisits AS PatientVisits_1
                            WHERE      (PatientID = @PatientId)))
  
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientAppointmentList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientAppointmentList]
           (@ConsultingDoc int
           ,@StartDataTime date
           ,@EndDataTime date)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  SELECT     dbo.PatientAppointment.AppDataTime, dbo.PatientAppointment.PatientId, 
                      dbo.PatientRegistration.SurName + ' ' + dbo.PatientRegistration.FirstName + ' ' + dbo.PatientRegistration.LastName AS PatientName, 
                      dbo.LookupsMaster.Name AS AppointmentType, dbo.PatientAppointment.AppConfirm
FROM         dbo.PatientAppointment INNER JOIN
                      dbo.LookupsMaster ON dbo.PatientAppointment.AppointmentType = dbo.LookupsMaster.ID INNER JOIN
                      dbo.PatientRegistration ON dbo.PatientAppointment.PatientId = dbo.PatientRegistration.PatientId
WHERE     (dbo.PatientAppointment.ConsultingDoc = @ConsultingDoc) AND (dbo.PatientAppointment.AppDataTime >= @StartDataTime) AND 
                      (dbo.PatientAppointment.AppDataTime <= @EndDataTime) Order by dbo.PatientAppointment.AppDataTime
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBill]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientBill]
            
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      SELECT     dbo.BillingMaster.BillID, dbo.BillingMaster.BillDate, dbo.BillingMaster.PatientID, 
                      dbo.PatientRegistration.SurName + ' ' + dbo.PatientRegistration.FirstName + ' ' + dbo.PatientRegistration.LastName AS PatientName, dbo.BillingMaster.Remarks, 
                      dbo.BillingMaster.GrAmt, dbo.BillingMaster.OtherCharges, dbo.BillingMaster.NetAmt, dbo.SecurityMaster.UserName, dbo.BillingMaster.CreatedDateTime, 
                      dbo.LookupsMaster.Name AS BillCategory
FROM         dbo.BillingMaster INNER JOIN
                      dbo.PatientRegistration ON dbo.BillingMaster.PatientID = dbo.PatientRegistration.PatientId INNER JOIN
                      dbo.SecurityMaster ON dbo.BillingMaster.CreatedBy = dbo.SecurityMaster.UserId LEFT OUTER JOIN
                      dbo.LookupsMaster ON dbo.BillingMaster.BillCategory = dbo.LookupsMaster.ID

END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByID]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientBillByID]
           (@BillID bigint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      SELECT     BillID, BillDate, PatientID, Remarks, GrAmt, OtherCharges, NetAmt,BillCategory
FROM         dbo.BillingMaster
WHERE     (BillID = @BillID)

END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDChargesDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

Create PROCEDURE [dbo].[Proc_GetPatientBillByIDChargesDetails]
           (@BillID bigint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
SELECT     dbo.LookupsMaster.Name, dbo.BillingCharges.Rate, dbo.BillingCharges.TotalAmt, dbo.BillingCharges.Charges, dbo.BillingCharges.BillID
FROM         dbo.BillingCharges INNER JOIN
                      dbo.LookupsMaster ON dbo.BillingCharges.Charges = dbo.LookupsMaster.ID
WHERE     (dbo.BillingCharges.BillID = @BillID)
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDItemDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

Create PROCEDURE [dbo].[Proc_GetPatientBillByIDItemDetails]
           (@BillID bigint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
     SELECT     TOP (100) PERCENT dbo.BillingDetails.BillID, dbo.ItemServiceMaster.Name AS ItemSrv, dbo.LookupsMaster.Name AS UnitName, dbo.ItemServiceMaster.ItemID, 
                      dbo.BillingDetails.Unit, dbo.BillingDetails.Rate, dbo.BillingDetails.TotalAmt, dbo.BillingDetails.ItemDesc, dbo.BillingDetails.ItemNo
FROM         dbo.BillingDetails INNER JOIN
                      dbo.ItemServiceMaster ON dbo.BillingDetails.ItemID = dbo.ItemServiceMaster.ItemID LEFT OUTER JOIN
                      dbo.LookupsMaster ON dbo.BillingDetails.Unit = dbo.LookupsMaster.ID
WHERE     (dbo.BillingDetails.BillID = @BillID)
ORDER BY dbo.BillingDetails.ItemNo
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientBillByIDPayDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientBillByIDPayDetails]
           (@BillID bigint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
SELECT     BillID, PayMode, ChequeDate, BankID, Amount, Cheque_CC_No
FROM         dbo.BillPayDetails
WHERE     (BillID = @BillID)
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientbyID]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientbyID]
	@PatientId bigint
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT     PatientId, FirstName, LastName, SurName, Gender, Address, [Telephone No], [Mobile No], [Contact Person], Email, Remarks, PatientType, RegistrationDate, 
                      RefByDoc, DOB, Age, Occupation, AssignedDr, MaritalStatus, Language, Religion, BloodGroup, SiblingBrother, SiblingSister, ChildBoys, ChildGirl, Diet, Image
	FROM         dbo.PatientRegistration
	WHERE     (PatientId = @PatientId )
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientInflowChartData]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientInflowChartData]
	@SYear int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT MONTH(RegistrationDate) AS SMonth, COUNT(PatientId) AS PatientCount FROM  dbo.PatientRegistration
		WHERE (YEAR(RegistrationDate) = @SYear) GROUP BY MONTH(RegistrationDate)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisit]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientVisit]
           (@PatientId bigint
           ,@VisitID smallint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      
	SELECT     VisitID, VisitDataTime, ConsultingDoc, CompalinedDiseases, VisitNote, PatientID
	FROM         dbo.PatientVisits
	WHERE     (VisitID = @VisitID) AND (PatientID = @PatientId)
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitDiagnosis]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientVisitDiagnosis]
           (@PatientId bigint
           ,@VisitID smallint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      
SELECT     dbo.PatienDiagnosis.PatientId, dbo.PatienDiagnosis.VisitID, dbo.Diagnosis.Diagnosis, dbo.PatienDiagnosis.DiagnosisDate, dbo.PatienDiagnosis.Status
FROM         dbo.PatienDiagnosis INNER JOIN
                      dbo.Diagnosis ON dbo.PatienDiagnosis.DiagnosisID = dbo.Diagnosis.DiagnosisID
WHERE     (dbo.PatienDiagnosis.PatientId = @PatientId) AND (dbo.PatienDiagnosis.VisitID = @VisitID)
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitExamFinding]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create PROCEDURE [dbo].[Proc_GetPatientVisitExamFinding]
           (@PatientId bigint
           ,@VisitID smallint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      
SELECT     dbo.PatientExamFinding.PatientId, dbo.PatientExamFinding.VisitID, dbo.LookupsMaster.Name AS Findings, LookupsMaster_1.Name AS FindCategory
FROM         dbo.PatientExamFinding INNER JOIN
                      dbo.LookupsMaster ON dbo.PatientExamFinding.Findings = dbo.LookupsMaster.ID INNER JOIN
                      dbo.LookupsMaster AS LookupsMaster_1 ON dbo.PatientExamFinding.FindCategory = LookupsMaster_1.ID
WHERE     (dbo.PatientExamFinding.PatientId = @PatientId) AND (dbo.PatientExamFinding.VisitID = @VisitID)
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitPrescription]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create PROCEDURE [dbo].[Proc_GetPatientVisitPrescription]
           (@PatientId bigint
           ,@VisitID smallint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      
	SELECT     dbo.PatientPrescription.PatientId, dbo.PatientPrescription.VisitID, dbo.ItemServiceMaster.Name, dbo.PatientPrescription.Dosage, 
                      dbo.LookupsMaster.Name AS Frequency, dbo.PatientPrescription.Duaration, dbo.PatientPrescription.Periods
FROM         dbo.PatientPrescription INNER JOIN
                      dbo.ItemServiceMaster ON dbo.PatientPrescription.MedicineItemID = dbo.ItemServiceMaster.ItemID LEFT OUTER JOIN
                      dbo.LookupsMaster ON dbo.PatientPrescription.Frequency = dbo.LookupsMaster.ID
WHERE     (dbo.PatientPrescription.PatientId = @PatientId) AND (dbo.PatientPrescription.VisitID = @VisitID)
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatientVisitProblems]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatientVisitProblems]
           (@PatientId bigint
           ,@VisitID smallint)    
    
AS      
BEGIN      
 -- SET NOCOUNT ON added to prevent extra result sets from      
 -- interfering with SELECT statements.      
 SET NOCOUNT ON;      
      
	SELECT     dbo.Problems.Problem, dbo.PatientProblems.Period, LookupsMaster_1.Name AS Severity, LookupsMaster_2.Name AS ProblemPeriod, 
                      dbo.LookupsMaster.Name AS ProblemTiming, LookupsMaster_3.Name AS ProblemDuration, LookupsMaster_4.Name AS ProblemLocation, dbo.PatientProblems.ReportedDateTime
FROM         dbo.PatientProblems INNER JOIN
                      dbo.Problems ON dbo.PatientProblems.Problem = dbo.Problems.ProblemID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_4 ON dbo.PatientProblems.ProblemLocation = LookupsMaster_4.ID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_3 ON dbo.PatientProblems.ProblemDuration = LookupsMaster_3.ID LEFT OUTER JOIN
                      dbo.LookupsMaster ON dbo.PatientProblems.ProblemTiming = dbo.LookupsMaster.ID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_2 ON dbo.PatientProblems.ProblemPeriod = LookupsMaster_2.ID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_1 ON dbo.PatientProblems.Severity = LookupsMaster_1.ID
WHERE     (dbo.PatientProblems.PatientId = @PatientId) AND (dbo.PatientProblems.VisitID = @VisitID)
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetPatienVisitInfo]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetPatienVisitInfo]  
           (@PatientId bigint)  
  
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
SELECT     dbo.Problems.Problem, dbo.PatientVisits.VisitID, dbo.PatientVisits.VisitDataTime, 
                      dbo.DoctorMaster.SurName + ' ' + dbo.DoctorMaster.FirstName + ' ' + dbo.DoctorMaster.LastName AS Doc, dbo.PatientVisits.VisitNote, 
                      dbo.LookupsMaster.Name AS VisitStatus
FROM         dbo.PatientVisits INNER JOIN
                      dbo.Problems ON dbo.PatientVisits.CompalinedDiseases = dbo.Problems.ProblemID INNER JOIN
                      dbo.DoctorMaster ON dbo.PatientVisits.ConsultingDoc = dbo.DoctorMaster.DrID LEFT OUTER JOIN
                      dbo.LookupsMaster ON dbo.PatientVisits.VisitStatus = dbo.LookupsMaster.ID
WHERE     (dbo.PatientVisits.PatientID = @PatientId)
  
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetProblemsCategoryWiseList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetProblemsCategoryWiseList]  
  @CategoryType int
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
SELECT  dbo.LookupsMaster.Name AS ProblemCategory, dbo.Problems.ProblemID, dbo.Problems.Problem, dbo.LookupsMaster.Type
FROM         dbo.LookupsMaster INNER JOIN
                      dbo.Problems ON dbo.LookupsMaster.ID = dbo.Problems.ProblemCategory
WHERE     (dbo.Problems.ProblemCategory = @CategoryType)
ORDER BY dbo.Problems.Problem
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetProblemsList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetProblemsList]  
  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
 SELECT     dbo.LookupsMaster.Name AS ProblemCategory, dbo.Problems.ProblemID, dbo.Problems.Problem  ,dbo.Problems.ChiefComplaint,
dbo.Problems.Remarks
FROM         dbo.LookupsMaster INNER JOIN  
                      dbo.Problems ON dbo.LookupsMaster.ID = dbo.Problems.ProblemCategory  
ORDER BY dbo.Problems.Problem  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetSalesChartData]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetSalesChartData]
	@SYear int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    SELECT     SUM(NetAmt) AS SaleAmt, YEAR(BillDate) AS SYear, MONTH(BillDate) AS SMonth
	FROM         dbo.BillingMaster WHERE     (YEAR(BillDate) = @SYear) GROUP BY YEAR(BillDate), MONTH(BillDate)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_GetTemplateItems]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

      
CREATE PROCEDURE [dbo].[Proc_GetTemplateItems]        
  @BillTemplateID int    
AS        
BEGIN        
 -- SET NOCOUNT ON added to prevent extra result sets from        
 -- interfering with SELECT statements.        
 SET NOCOUNT ON;        
        
  SELECT     TOP (100) PERCENT dbo.ItemServiceMaster.ItemNo, dbo.ItemServiceMaster.Name, LookupsMaster_1.Name AS Category, dbo.ItemServiceMaster.Rate,     
                      dbo.LookupsMaster.Name AS UnitName, dbo.ItemServiceMaster.Unit, dbo.ItemServiceMaster.Remarks, dbo.ItemServiceMaster.ItemID,     
                      dbo.ItemServiceMaster.IsInventoryItem, LookupsMaster_2.Name AS SubCategory    
FROM         dbo.LookupsMaster AS LookupsMaster_1 RIGHT OUTER JOIN    
                      dbo.BillTemplateDetails INNER JOIN    
                      dbo.ItemServiceMaster INNER JOIN    
                      dbo.LookupsMaster ON dbo.ItemServiceMaster.Unit = dbo.LookupsMaster.ID ON dbo.BillTemplateDetails.ItemID = dbo.ItemServiceMaster.ItemID ON     
                      LookupsMaster_1.ID = dbo.ItemServiceMaster.CategoryID LEFT OUTER JOIN    
                      dbo.LookupsMaster AS LookupsMaster_2 ON dbo.ItemServiceMaster.SubCategoryID = LookupsMaster_2.ID    
WHERE     (dbo.BillTemplateDetails.BillTemplateID = @BillTemplateID)    
ORDER BY ItemOrderNo  
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_GetTreatmentProceduresList]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_GetTreatmentProceduresList]

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

SELECT     TOP (100) PERCENT dbo.LookupsMaster.Name AS ProcedureCategory, dbo.TreatmentProcedures.ProcedureID, dbo.TreatmentProcedures.ProcedureDesc, 
                      dbo.TreatmentProcedures.Remarks
FROM         dbo.LookupsMaster INNER JOIN
                      dbo.TreatmentProcedures ON dbo.LookupsMaster.ID = dbo.TreatmentProcedures.ProcedureCategory
ORDER BY dbo.TreatmentProcedures.ProcedureDesc
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_AlertsReminder]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_AlertsReminder]
           (@AlertSubject varchar(50)
           ,@AlertNote varchar(500)
           ,@AlertDate date
           ,@Createdby int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO [dbo].[AlertsReminder]
           ([AlertSubject]
           ,[AlertNote]
           ,[AlertDate]
           ,[Createdby])
     VALUES
           (@AlertSubject 
           ,@AlertNote
           ,@AlertDate
           ,@Createdby)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Banks]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_Banks]
	       (@BankName varchar(100)
           ,@BranchName varchar(100)
           ,@Address varchar(200)
           ,@TelNo varchar(50))

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[BankMaster]
           ([BankName]
           ,[BranchName]
           ,[Address]
           ,[TelNo])
     VALUES
           (@BankName
           ,@BranchName
           ,@Address
           ,@TelNo)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Bill]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_Bill]
           (@BillDate smalldatetime
           ,@PatientID int
           ,@Remarks varchar(500)
           ,@GrAmt numeric(18,2)
           ,@OtherCharges numeric(18,2)
           ,@NetAmt numeric(18,2)
           ,@CreatedBy int
           ,@BillCategory int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[BillingMaster]
           ([BillDate]
           ,[PatientID]
           ,[Remarks]
           ,[GrAmt]
           ,[OtherCharges]
           ,[NetAmt]
           ,[CreatedBy]
           ,[BillCategory])
     VALUES
           (@BillDate 
           ,@PatientID
           ,@Remarks
           ,@GrAmt
           ,@OtherCharges
           ,@NetAmt
           ,@CreatedBy
           ,@BillCategory)

SELECT @@IDENTITY
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillChargesDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_BillChargesDetails]
           (@BillID bigint
           ,@Charges int
           ,@Rate float
           ,@TotalAmt float)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[BillingCharges]
           ([BillID]
           ,[Charges]
           ,[Rate]
           ,[TotalAmt])
     VALUES
           (@BillID
           ,@Charges
           ,@Rate
           ,@TotalAmt)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillItemsDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_BillItemsDetails]
           (@BillID bigint
           ,@ItemID int
           ,@Qty float
           ,@Unit int
           ,@Rate float
           ,@TotalAmt float
           ,@ItemDesc varchar(100)
           ,@BatchNo varchar(50)
           ,@ItemNo smallint)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[BillingDetails]
           ([BillID]
           ,[ItemID]
           ,[Qty]
           ,[Unit]
           ,[Rate]
           ,[TotalAmt]
           ,[ItemDesc]
           ,[BatchNo]
           ,[ItemNo])
     VALUES
           (@BillID
           ,@ItemID
           ,@Qty
           ,@Unit
           ,@Rate
           ,@TotalAmt
           ,@ItemDesc
           ,@BatchNo
           ,@ItemNo)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillPaymentDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_BillPaymentDetails]  
           (@BillID bigint  
           ,@PayMode int  
           ,@Cheque_CC_No varchar(20)  
           ,@ChequeDate date  
           ,@BankID int  
           ,@Amount numeric(18,2))  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
 INSERT INTO [dbo].[BillPayDetails]  
           ([BillID]  
           ,[PayMode]  
           ,[Cheque_CC_No]  
           ,[ChequeDate]  
           ,[BankID]  
           ,[Amount])  
     VALUES  
           (@BillID  
           ,@PayMode  
           ,@Cheque_CC_No  
           ,@ChequeDate  
           ,@BankID  
           ,@Amount)  
  SELECT @@IDENTITY
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillTemplateDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_BillTemplateDetails]
           (@BillTemplateID smallint
           ,@ItemID bigint
           ,@ItemOrderNo smallint)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[BillTemplateDetails]
           ([BillTemplateID]
           ,[ItemID]
           ,[ItemOrderNo])
     VALUES
           (@BillTemplateID
           ,@ItemID
           ,@ItemOrderNo)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_BillTemplates]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_BillTemplates]
           (@TemplateName varchar(100)
           ,@Remarks varchar(500)
           ,@CreatedBy int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [BillTemplates]
           ([TemplateName]
           ,Remarks
           ,[CreatedBy]
           ,[CreatedDateTime])
     VALUES
           (@TemplateName
           ,@Remarks
           ,@CreatedBy
           ,GETDATE())

SELECT @@IDENTITY

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DepartmentMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_DepartmentMaster]
           (@DeptName varchar(50)
           ,@Charges int
           ,@Incharge int
           ,@Remarks varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO [dbo].[DepartmentMaster]
           ([DeptName]
           ,[Charges]
           ,[Incharge]
           ,[Remarks])
     VALUES
           (@DeptName
           ,@Charges
           ,@Incharge
           ,@Remarks)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Diagnosis]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_Insert_Diagnosis]
           (@Diagnosis varchar(500)
           ,@ParentID int
           ,@Remarks varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[Diagnosis]
           ([Diagnosis]
           ,[ParentID]
           ,[Remarks])
     VALUES
           (@Diagnosis
           ,@ParentID
           ,@Remarks)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DiseasesMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_DiseasesMaster]
           (@Diseases varchar(1000))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

 INSERT INTO [dbo].[DiseasesMaster]
           ([Diseases])
     VALUES
           (@Diseases)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_DoctorMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_DoctorMaster]
           (@FirstName varchar(100)
           ,@LastName varchar(100)
           ,@SurName varchar(50)
           ,@Address varchar(200)
           ,@TelephoneNo varchar(50)
           ,@MobileNo varchar(30)
           ,@Gender bit
           ,@Age numeric(5,2)
           ,@LicenseNo varchar(50)
           ,@Specialization int
           ,@DrType int
           ,@ConsultationCharge int)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[DoctorMaster]
           ([FirstName]
           ,[LastName]
           ,[SurName]
           ,[Address]
           ,[TelephoneNo]
           ,[MobileNo]
           ,[Gender]
           ,[Age]
           ,[LicenseNo]
           ,[Specialization]
           ,[DrType]
           ,[ConsultationCharge])
     VALUES
           (@FirstName
           ,@LastName
           ,@SurName
           ,@Address
           ,@TelephoneNo
           ,@MobileNo
           ,@Gender
           ,@Age
           ,@LicenseNo
           ,@Specialization
           ,@DrType
           ,@ConsultationCharge)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_EmpMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_EmpMaster]
           (@EmpNo varchar(50)
           ,@FirstName varchar(100)
           ,@LastName varchar(100)
           ,@SurName varchar(50)
           ,@Address varchar(200)
           ,@TelephoneNo varchar(50)
           ,@MobileNo varchar(30)
           ,@EmpType int
           ,@Gender bit
           ,@Age numeric(5,2))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[EmpMaster]
           ([EmpNo]
           ,[FirstName]
           ,[LastName]
           ,[SurName]
           ,[Address]
           ,[Telephone No]
           ,[Mobile No]
           ,[EmpType]
           ,[Gender]
           ,[Age])
     VALUES
           (@EmpNo
           ,@FirstName
           ,@LastName
           ,@SurName
           ,@Address
           ,@TelephoneNo
           ,@MobileNo
           ,@EmpType
           ,@Gender
           ,@Age)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Findings]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_Findings]
	(@FindingCategory int
           ,@Finding varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[Findings]
           ([FindingCategory]
           ,[Finding])
     VALUES
           (@FindingCategory
           ,@Finding)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Investigation]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_Investigation]
	       (@Investigation varchar(200)
           ,@InvestigationCategory int
           ,@Remarks varchar(500))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT INTO [dbo].[Investigations]
           ([Investigation]
           ,[InvestigationCategory]
           ,[Remarks])
     VALUES
           (@Investigation
           ,@InvestigationCategory
           ,@Remarks)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_ItemServiceMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_ItemServiceMaster]    
           (@ItemNo varchar(20)    
           ,@Name varchar(100)    
           ,@CategoryID smallint    
           ,@Rate float    
           ,@Unit int    
           ,@Remarks varchar(200)    
           ,@IsInventoryItem bit    
           ,@SubCategoryID smallint  
           ,@ROL numeric(10,2))    
    
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
INSERT INTO [dbo].[ItemServiceMaster]    
           ([ItemNo]    
           ,[Name]    
           ,[CategoryID]    
           ,[Rate]    
           ,[Unit]    
           ,[Remarks]    
           ,[IsInventoryItem]    
           ,[SubCategoryID],ROL)    
     VALUES    
           (@ItemNo    
           ,@Name    
           ,@CategoryID    
           ,@Rate    
           ,@Unit    
           ,@Remarks    
           ,@IsInventoryItem    
           ,@SubCategoryID,@ROL)   
           
           SELECT @@IDENTITY 
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_LookupsMaster]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_LookupsMaster]  
           (@Name varchar(100)  
           ,@Type varchar(50)  
           ,@Rate float
           ,@Remarks varchar(50)  )  
  
AS  
BEGIN  
 INSERT INTO [dbo].[LookupsMaster]  
           ([Name]  
           ,[Type]  
           ,[Rate]
           ,Remarks)  
     VALUES  
           (@Name  
           ,@Type  
           ,@Rate
           ,@Remarks)  
  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_MedicineItemsDtl]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

Create PROCEDURE [dbo].[Proc_Insert_MedicineItemsDtl]   
           (@ItemID bigint
           ,@Strenght varchar(50)
           ,@MedicineType int
           ,@GenericDrug int
           ,@Mfg int
           ,@Composition varchar(100)
           ,@ShelfNo varchar(10)
           ,@RackNo varchar(10)
           ,@BoxNo varchar(10))

    
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
INSERT INTO [dbo].[MedicineItemsDtl]
           ([ItemID]
           ,[Strenght]
           ,[MedicineType]
           ,[GenericDrug]
           ,[Mfg]
           ,[Composition]
           ,[ShelfNo]
           ,[RackNo]
           ,[BoxNo])
     VALUES
           (@ItemID
           ,@Strenght
           ,@MedicineType
           ,@GenericDrug
           ,@Mfg
           ,@Composition
           ,@ShelfNo
           ,@RackNo
           ,@BoxNo)

END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatienDiagnosis]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatienDiagnosis]
           (@PatientId bigint
           ,@PatienDiagnosisID smallint
           ,@VisitID smallint
           ,@DiagnosisID int
           ,@DiagnosisDate date
           ,@Status varchar(100))

AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
INSERT INTO [dbo].[PatienDiagnosis]
           ([PatientId]
           ,[PatienDiagnosisID]
           ,VisitID
           ,[DiagnosisID]
           ,[DiagnosisDate]
           ,[Status])
     VALUES
           (@PatientId
           ,@PatienDiagnosisID
           ,@VisitID
           ,@DiagnosisID
           ,@DiagnosisDate
           ,@Status)

END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientAddmissionInfo]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_Insert_PatientAddmissionInfo]
           (@PatientID bigint
           ,@AdminssionDate date
           ,@WardID int
           ,@DeptID int
           ,@RoomNo int
           ,@Diseases varchar(500)
           ,@Remarks varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	Declare @PID bigint
	
	SET @PID = 0

	Select @PID = [PatientID] From [PatientAddmissionInfo] WHERE [PatientID] = @PatientID

	IF @PID = 0
		INSERT INTO [dbo].[PatientAddmissionInfo]
           ([PatientID]
           ,[AdminssionDate]
           ,[WardID]
           ,[DeptID]
           ,[RoomNo]
           ,[Diseases]
           ,[Remarks])
		VALUES
           (@PatientID
           ,@AdminssionDate
           ,@WardID
           ,@DeptID
           ,@RoomNo
           ,@Diseases
           ,@Remarks)
    Else
		UPDATE [HMSIndia].[dbo].[PatientAddmissionInfo]
		   SET [AdminssionDate] = @AdminssionDate
			  ,[WardID] = @WardID
			  ,[DeptID] = @DeptID
			  ,[RoomNo] = @RoomNo
			  ,[Diseases] = @Diseases
			  ,[Remarks] = @Remarks
		 WHERE [PatientID] = @PatientID


END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientAppointment]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientAppointment]
           (@PatientId bigint
           ,@ConsultationRoom int
           ,@ConsultingDoc int
           ,@AppDataTime datetime
           ,@AppointmentType int
           ,@AppointmentStatus int
           ,@AppConfirm bit
           ,@AppTentative bit)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO [dbo].[PatientAppointment]
           ([PatientId]
           ,[ConsultationRoom]
           ,[ConsultingDoc]
           ,[AppDataTime]
           ,[AppointmentType]
           ,[AppointmentStatus]
           ,[AppConfirm]
           ,[AppTentative])
     VALUES
           (@PatientId
           ,@ConsultationRoom
           ,@ConsultingDoc
           ,@AppDataTime
           ,@AppointmentType
           ,@AppointmentStatus
           ,@AppConfirm
           ,@AppTentative)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientExamFinding]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientExamFinding]
           (@PatientId bigint
           ,@ExamID smallint
           ,@VisitID smallint
           ,@FindCategory int
           ,@Findings int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[PatientExamFinding]
           ([PatientId]
           ,[ExamID]
           ,VisitID
           ,[FindCategory]
           ,[Findings])
     VALUES
           (@PatientId
           ,@ExamID
           ,@VisitID
           ,@FindCategory
           ,@Findings)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientGuardians]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientGuardians]  
        (@PatientID bigint  
           ,@GuardianName varchar(50)  
           ,@Relationship int  
           ,@ContactNo varchar(50)
           ,@HealthStatus	int	
			,@Age	numeric(5, 2)	
			,@Diseases	varchar(200)
			,@Notes	varchar(200))  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
 INSERT INTO [dbo].[PatientGuardians]  
           ([PatientID]  
           ,[GuardianName]  
           ,[Relationship]  
           ,[ContactNo]
           ,HealthStatus	
			,Age	
			,Diseases	
			,Notes	)  
     VALUES  
           (@PatientID  
           ,@GuardianName  
           ,@Relationship  
           ,@ContactNo
           ,@HealthStatus	
			,@Age	
			,@Diseases	
			,@Notes	)  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientPrescription]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientPrescription]
           (@PatientId bigint
           ,@PrescriptionID smallint
           ,@VisitID smallint
           ,@MedicineItemID bigint
           ,@Dosage float
           ,@Frequency int
           ,@Duaration float
           ,@Periods varchar(20))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    INSERT INTO [dbo].[PatientPrescription]
           ([PatientId]
           ,[PrescriptionID]
           ,VisitID
           ,[MedicineItemID]
           ,[Dosage]
           ,[Frequency]
           ,[Duaration]
           ,[Periods])
     VALUES
           (@PatientId
           ,@PrescriptionID
           ,@VisitID
           ,@MedicineItemID
           ,@Dosage
           ,@Frequency
           ,@Duaration
           ,@Periods)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientProblems]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientProblems]
           (@PatientId bigint
           ,@ProblemID smallint
           ,@VisitID smallint
           ,@ReportedDateTime date
           ,@ReportedDr int
           ,@Problem int
           ,@Period float
           ,@ProblemPeriod int
           ,@ProblemTiming int
           ,@ProblemDuration int
           ,@ProblemLocation int
           ,@Severity int
           ,@Comments varchar(500))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[PatientProblems]
           ([PatientId]
           ,[ProblemID]
           ,VisitID
           ,[ReportedDateTime]
           ,[ReportedDr]
           ,[Problem]
           ,[Period]
           ,[ProblemPeriod]
           ,[ProblemTiming]
           ,[ProblemDuration]
           ,[ProblemLocation]
           ,[Severity]
           ,[Comments])
     VALUES
           (@PatientId
           ,@ProblemID
           ,@VisitID
           ,@ReportedDateTime
           ,@ReportedDr
           ,@Problem
           ,@Period
           ,@ProblemPeriod
           ,@ProblemTiming
           ,@ProblemDuration
           ,@ProblemLocation
           ,@Severity
           ,@Comments)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientRegistration]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientRegistration]    
           (@FirstName varchar(100)    
           ,@LastName varchar(100)    
           ,@SurName varchar(50)    
           ,@Gender bit    
           ,@Address varchar(200)    
           ,@TelephoneNo varchar(50)    
           ,@MobileNo varchar(50)    
           ,@ContactPerson varchar(100)    
           ,@Email varchar(50)    
           ,@Remarks varchar(200)    
           ,@PatientType int    
           ,@RegistrationDate date    
           ,@RefByDoc varchar(50)    
           ,@DOB date    
           ,@Age numeric(5,2)    
           ,@Occupation varchar(50)    
           ,@AssignedDr int    
           ,@MaritalStatus int    
           ,@CreatedBy int
           ,@Language int
           ,@Religion int
           ,@BloodGroup int
           ,@Diet int
           ,@SiblingBrother tinyint
           ,@SiblingSister tinyint
           ,@ChildBoys tinyint
           ,@ChildGirl tinyint
           ,@Image	varbinary(MAX))    
    
AS    
BEGIN    
 -- SET NOCOUNT ON added to prevent extra result sets from    
 -- interfering with SELECT statements.    
 SET NOCOUNT ON;    
    
    -- Insert statements for procedure here    
INSERT INTO [dbo].[PatientRegistration]    
           ([FirstName]    
           ,[LastName]    
           ,[SurName]    
           ,[Gender]    
           ,[Address]    
           ,[Telephone No]    
           ,[Mobile No]    
           ,[Contact Person]    
           ,[Email]    
           ,[Remarks]    
           ,[PatientType]    
           ,[RegistrationDate]    
           ,[RefByDoc]    
           ,[DOB]    
           ,[Age]    
           ,[Occupation]    
           ,[AssignedDr]    
           ,[MaritalStatus]    
           ,[CreatedBy]    
           ,[CreatedDateTime]
           ,[Language]
           ,Religion 
           ,BloodGroup 
           ,Diet 
           ,SiblingBrother 
           ,SiblingSister 
           ,ChildBoys 
           ,ChildGirl
           ,[Image] )    
     VALUES    
           (@FirstName    
           ,@LastName    
           ,@SurName    
           ,@Gender    
           ,@Address    
           ,@TelephoneNo    
           ,@MobileNo    
           ,@ContactPerson    
           ,@Email    
           ,@Remarks    
           ,@PatientType    
           ,@RegistrationDate    
           ,@RefByDoc    
           ,@DOB    
           ,@Age    
           ,@Occupation    
           ,@AssignedDr    
           ,@MaritalStatus    
           ,@CreatedBy    
           ,GETDATE()
           ,@Language 
           ,@Religion 
           ,@BloodGroup 
           ,@Diet 
           ,@SiblingBrother 
           ,@SiblingSister 
           ,@ChildBoys 
           ,@ChildGirl
           ,@Image)    
 Select @@IDENTITY  
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PatientVisits]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PatientVisits]
           (@PatientID bigint
           ,@VisitID smallint
           ,@VisitDataTime date
           ,@ConsultingDoc int
           ,@ConsultationRoom int
           ,@VisitStatus int
           ,@CompalinedDiseases int
           ,@FollowUpID int
           ,@VisitNote varchar(500))
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
INSERT INTO [dbo].[PatientVisits]
           ([PatientID]
           ,[VisitID]
           ,[VisitDataTime]
           ,[ConsultingDoc]
           ,[ConsultationRoom]
           ,[VisitStatus]
           ,[CompalinedDiseases]
           ,[FollowUpID]
           ,[VisitNote])
     VALUES
           (@PatientID
           ,@VisitID
           ,@VisitDataTime
           ,@ConsultingDoc
           ,@ConsultationRoom
           ,@VisitStatus
           ,@CompalinedDiseases
           ,@FollowUpID
           ,@VisitNote)
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PrescriptionTempDetails]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PrescriptionTempDetails]
	       (@PrescriptionTempID int
	       ,@PrescriptionTempDtlID smallint
           ,@MedicineItemID bigint
           ,@Dosage float
           ,@Frequency int
           ,@Duaration float
           ,@Periods varchar(20))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  INSERT INTO [dbo].[PrescriptionTempDetails]
           ([PrescriptionTempID]
           ,[PrescriptionTempDtlID]
           ,[MedicineItemID]
           ,[Dosage]
           ,[Frequency]
           ,[Duaration]
           ,[Periods])
     VALUES
           (@PrescriptionTempID
           ,@PrescriptionTempDtlID
           ,@MedicineItemID
           ,@Dosage
           ,@Frequency
           ,@Duaration
           ,@Periods)
           

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_PrescriptionTemplate]    Script Date: 09/07/2014 09:18:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_PrescriptionTemplate]
	       (@Prescription varchar(100)
           ,@Remarks varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO [dbo].[PrescriptionTemplate]
           ([Prescription]
           ,[Remarks])
     VALUES
           (@Prescription
           ,@Remarks)
           
     SELECT @@IDENTITY

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_Problem]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_Problem]  
        (@Problem varchar(200)  
           ,@ProblemCategory int
           ,@ChiefComplaint	bit
			,@Remarks	varchar(200)	)  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
 INSERT INTO [dbo].[Problems]  
           ([ProblemCategory]  
           ,[Problem]
           ,ChiefComplaint
           ,Remarks)  
     VALUES  
           (@ProblemCategory  
           ,@Problem
           ,@ChiefComplaint
           ,@Remarks)  
  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_RoomMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_RoomMaster]
           (@RoomNo varchar(50)
           ,@DeptID int
           ,@WardID int
           ,@RoomCost int
           ,@Remarks varchar(200))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[RoomMaster]
           ([RoomNo]
           ,[DeptID]
           ,[WardID]
           ,[RoomCost]
           ,[Remarks])
     VALUES
           (@RoomNo
           ,@DeptID
           ,@WardID
           ,@RoomCost
           ,@Remarks)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_SecurityMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_SecurityMaster]
           (@UserName varchar(50)
           ,@Password varchar(100)
           ,@CreatedBy smallint
           ,@IsSuperUser bit
           ,@PassQuestion varchar(100)
           ,@PassAns varchar(50)
           ,@ProfileID smallint)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[SecurityMaster]
           ([UserName]
           ,[Password]
           ,[CreatedBy]
           ,[CreatedDatetime]
           ,[IsSuperUser]
           ,[PassQuestion]
           ,[PassAns]
           ,[ProfileID])
     VALUES
           (@UserName
           ,@Password
           ,@CreatedBy
           ,GETDATE()
           ,@IsSuperUser
           ,@PassQuestion
           ,@PassAns
           ,@ProfileID)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_SupplierMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_SupplierMaster]
           (@Name varchar(100)
           ,@Address varchar(200)
           ,@Address1 varchar(200)
           ,@TelephoneNo varchar(50)
           ,@MobileNo varchar(30)
           ,@ContactPerson varchar(50)
           ,@Email varchar(30)
           ,@CreditLimit float
           ,@CreditPeriod smallint)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [HMSIndia].[dbo].[SupplierMaster]
           ([Name]
           ,[Address]
           ,[Address1]
           ,[Telephone No]
           ,[Mobile No]
           ,[Contact Person]
           ,[Email]
           ,[CreditLimit]
           ,[CreditPeriod])
     VALUES
           (@Name
           ,@Address
           ,@Address1
           ,@TelephoneNo
           ,@MobileNo
           ,@ContactPerson
           ,@Email
           ,@CreditLimit
           ,@CreditPeriod)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_TreatmentProcedures]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_TreatmentProcedures]
           (@ProcedureDesc varchar(100)
           ,@ProcedureCategory int
           ,@Remarks varchar(500))

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT INTO [dbo].[TreatmentProcedures]
           ([ProcedureDesc]
           ,[ProcedureCategory]
           ,[Remarks])
     VALUES
           (@ProcedureDesc
           ,@ProcedureCategory
           ,@Remarks)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Insert_WardMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Insert_WardMaster]
           (@WardNo varchar(50)
           ,@DeptID int
           ,@Remarks varchar(200))

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[WardMaster]
           ([WardNo]
           ,[DeptID]
           ,[Remarks])
     VALUES
           (@WardNo
           ,@DeptID
           ,@Remarks)
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertModulePermissions]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_InsertModulePermissions]
           (@ProfileID int
           ,@ModuleID int
           ,@PAdd bit
           ,@PEdit bit
           ,@PDelete bit
           ,@PView bit
           ,@PPrint bit)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  INSERT INTO [dbo].[ModulePermissions]
           ([ModuleID]
           ,[ProfileID]
           ,[PAdd]
           ,[PEdit]
           ,[PDelete]
           ,[PView]
           ,[PPrint])
     VALUES
           (@ModuleID
           ,@ProfileID
           ,@PAdd
           ,@PEdit
           ,@PDelete
           ,@PView
           ,@PPrint)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPatientPayDetails]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPatientPayDetails]
	       (@PatientID bigint
           ,@PayID bigint
           ,@ReceivedBy int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO [dbo].[PatientPayDetails]
           ([PatientID]
           ,[PayID]
           ,[ReceivedBy]
           ,[ReceivedDataTime])
     VALUES
           (@PatientID
           ,@PayID
           ,@ReceivedBy
           ,GETDATE())
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseDetails]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPurchaseDetails]
           (@InvoiceID bigint
           ,@ItemID bigint
           ,@Qty float
           ,@Unit int
           ,@Rate float
           ,@TotalAmt float
           ,@ItemDesc varchar(50)
           ,@BatchNoFrom varchar(50)
           ,@SrNoUpto int
           ,@ItemNo smallint)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[PurchaseDetails]
           ([InvoiceID]
           ,[ItemID]
           ,[Qty]
           ,[Unit]
           ,[Rate]
           ,[TotalAmt]
           ,[ItemDesc]
           ,[BatchNoFrom]
           ,[SrNoUpto]
           ,[ItemNo])
     VALUES
           (@InvoiceID
           ,@ItemID
           ,@Qty
           ,@Unit
           ,@Rate
           ,@TotalAmt
           ,@ItemDesc
           ,@BatchNoFrom
           ,@SrNoUpto
           ,@ItemNo)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPurchaseMaster]
           (@VendorID int
           ,@InvDate date
           ,@Remarks varchar(500)
           ,@GrossAmt float
           ,@TaxDisc float
           ,@NetAmt float
           ,@CreatedBy int,
           @InvoiceNo varchar(50))
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT INTO [dbo].[PurchaseMaster]
           ([InvoiceNo]
           ,[VendorID]
           ,[InvDate]
           ,[Remarks]
           ,[GrossAmt]
           ,[TaxDisc]
           ,[NetAmt]
           ,[CreatedBy]
           ,[CreatedDateTime])
     VALUES
           (@InvoiceNo
           ,@VendorID
           ,@InvDate
           ,@Remarks
           ,@GrossAmt
           ,@TaxDisc
           ,@NetAmt
           ,@CreatedBy
           ,GetDate())

SELECT @@IDENTITY

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseOrder]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPurchaseOrder]
           (@VendorID int
           ,@OrdDate date
           ,@Remarks varchar(500)
           ,@GrossAmt float
           ,@TaxDisc float
           ,@NetAmt float
           ,@CreatedBy int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[PurchaseOrder]
           ([VendorID]
           ,[OrdDate]
           ,[Remarks]
           ,[GrossAmt]
           ,[TaxDisc]
           ,[NetAmt]
           ,[CreatedBy]
           ,[CreatedDateTime])
     VALUES
           (@VendorID
           ,@OrdDate
           ,@Remarks
           ,@GrossAmt
           ,@TaxDisc
           ,@NetAmt
           ,@CreatedBy
           ,GetDate())

SELECT @@IDENTITY

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseOrderDtl]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPurchaseOrderDtl]
           (@OrderNo int
           ,@ItemID bigint
           ,@Qty float
           ,@Unit int
           ,@Rate float
           ,@TotalAmt float
           ,@ItemDesc varchar(50)
           ,@ItemNo smallint)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[PurchaseOrderDtl]
           ([OrderNo]
           ,[ItemID]
           ,[Qty]
           ,[Unit]
           ,[Rate]
           ,[TotalAmt]
           ,[ItemDesc]
           ,[ItemNo])
     VALUES
           (@OrderNo
           ,@ItemID
           ,@Qty
           ,@Unit
           ,@Rate
           ,@TotalAmt
           ,@ItemDesc
           ,@ItemNo)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertPurchaseTaxDiscDtl]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertPurchaseTaxDiscDtl]
           (@InvoiceID bigint
           ,@Charges int
           ,@Rate float
           ,@TotalAmt float)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

INSERT INTO [dbo].[PurchaseTaxDiscDtl]
           ([InvoiceID]
           ,[Charges]
           ,[Rate]
           ,[TotalAmt])
     VALUES
           (@InvoiceID
           ,@Charges
           ,@Rate
           ,@TotalAmt)

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_InsertUserProfile]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_InsertUserProfile]
	@ProfileName varchar(100)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   INSERT INTO [dbo].[UserProfile]
           ([ProfileName]
           ,[CreatedateTime])
     VALUES
           (@ProfileName,GETDATE())
           
Select @@IDENTITY
END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Select_PrescriptionTempDetails]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Select_PrescriptionTempDetails]  
        (@PrescriptionTempID int )  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  SELECT     TOP (100) PERCENT dbo.PrescriptionTempDetails.PrescriptionTempID, dbo.PrescriptionTempDetails.PrescriptionTempDtlID, 
                      dbo.PrescriptionTempDetails.MedicineItemID, dbo.ItemServiceMaster.Name, dbo.PrescriptionTempDetails.Dosage, LookupsMaster_1.Name AS FrequencyName, 
                      dbo.PrescriptionTempDetails.Frequency, dbo.PrescriptionTempDetails.Duaration, dbo.PrescriptionTempDetails.Periods
FROM         dbo.PrescriptionTempDetails INNER JOIN
                      dbo.ItemServiceMaster ON dbo.PrescriptionTempDetails.MedicineItemID = dbo.ItemServiceMaster.ItemID LEFT OUTER JOIN
                      dbo.LookupsMaster AS LookupsMaster_1 ON dbo.PrescriptionTempDetails.Frequency = LookupsMaster_1.ID
WHERE     (dbo.PrescriptionTempDetails.PrescriptionTempID = @PrescriptionTempID)
ORDER BY dbo.PrescriptionTempDetails.PrescriptionTempDtlID
             
  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_CompanyMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Update_CompanyMaster]
	@CompanyName varchar(100)
      ,@Address_Office varchar(200)
      ,@TelephoneNo varchar(50)
      ,@Description varchar(200)
      ,@TinVAT varchar(50)
      ,@TinCST varchar(50)
      ,@InvoiceTerm varchar(1000)
      ,@ItemNoAuto bit
      ,@BillPrefix varchar(6)
      ,@BillCrNo bigint
      ,@BillSufix varchar(6)
AS
BEGIN
	UPDATE [dbo].[CompanyMaster]
   SET [Company Name] = @CompanyName
      ,[Address_Office] = @Address_Office
      ,[Telephone No] = @TelephoneNo
      ,[Description] = @Description
      ,[Tin VAT] = @TinVAT
      ,[Tin CST] = @TinCST
      ,[InvoiceTerm] = @InvoiceTerm
      ,[ItemNoAuto] = @ItemNoAuto
      ,[BillPrefix] = @BillPrefix
      ,[BillCrNo] = @BillCrNo
      ,[BillSufix] = @BillSufix

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_Diagnosis]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[Proc_Update_Diagnosis]
           (@Diagnosis varchar(500)
           ,@ParentID int
           ,@Remarks varchar(200)
           ,@DiagnosisID int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	UPDATE [dbo].[Diagnosis]
	SET [Diagnosis] = @Diagnosis
      ,[ParentID] = @ParentID
      ,[Remarks] = @Remarks
	WHERE [DiagnosisID] = @DiagnosisID

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_Update_LookupsMaster]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_Update_LookupsMaster]    
           (@Name varchar(100)    
           ,@Type varchar(50)    
           ,@Rate float
            ,@Remarks varchar(50)        
           ,@ID int)    
    
AS    
BEGIN    
 UPDATE [dbo].[LookupsMaster]    
    SET [Name] = @Name    
    ,[Type] = @Type    
    ,[Rate] = @Rate 
    ,Remarks = @Remarks   
  WHERE ID = @ID AND SystemDefined = 0  
    
    
END 
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateFinding]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_UpdateFinding]
	(@FindingCategory int
           ,@Finding varchar(200)
           ,@FindingID int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

   UPDATE [dbo].[Findings]
   SET [FindingCategory] = @FindingCategory
      ,[Finding] = @Finding
 WHERE FindingID = @FindingID

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateInvestigations]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_UpdateInvestigations]
	(@Investigation varchar(200)
           ,@InvestigationCategory int
           ,@Remarks varchar(500)
           ,@ID int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  UPDATE [dbo].[Investigations]
   SET [Investigation] = @Investigation
      ,[InvestigationCategory] = @InvestigationCategory
      ,[Remarks] = @Remarks
 WHERE  InvestigationID = @ID

END

GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateProblem]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_UpdateProblem]  
 (@Problem varchar(200)  
           ,@ProblemCategory int
           ,@ChiefComplaint	bit
			,@Remarks	varchar(200)  
           ,@ID int)  
AS  
BEGIN  
 -- SET NOCOUNT ON added to prevent extra result sets from  
 -- interfering with SELECT statements.  
 SET NOCOUNT ON;  
  
 UPDATE [dbo].[Problems]  
   SET [ProblemCategory] = @ProblemCategory  
      ,[Problem] = @Problem  
      ,ChiefComplaint =@ChiefComplaint
           ,Remarks = @Remarks
 WHERE  ProblemID = @ID  
  
END  
GO

/****** Object:  StoredProcedure [dbo].[Proc_UpdateTreatmentProcedures]    Script Date: 09/07/2014 09:18:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Proc_UpdateTreatmentProcedures]
           (@ProcedureDesc varchar(100)
           ,@ProcedureCategory int
           ,@Remarks varchar(500)
           ,@ID int)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

UPDATE [dbo].[TreatmentProcedures]
   SET [ProcedureDesc] = @ProcedureDesc
      ,[ProcedureCategory] = @ProcedureCategory
      ,[Remarks] = @Remarks
 WHERE  ProcedureID = @ID

END

GO


